#ifndef __ESP_INSTANCE_WINDOW_H__
#define __ESP_INSTANCE_WINDOW_H__
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#include "freertos/task.h"

#include "BlockScriptWindow.h"

#include "drivers/lcd/bsp_lcd.h"
#include "drivers/i2c/bsp_i2c.h"
#include "drivers/porting.h"

// #include "MainWindow.h"

typedef BlockScriptWindow MainWindow;

class EspInstanceWindow : public MainWindow
{
    typedef struct ARGB8888
    {
        unsigned char m_alpha;
        unsigned char m_red;
        unsigned char m_green;
        unsigned char m_blue;
    } ARGB8888;

    typedef struct RGB565
    {
        unsigned short m_red : 5;
        unsigned short m_green : 6;
        unsigned short m_blue : 5;
    } RGB565;

public:
    static EspInstanceWindow *GetInstance()
    {
        static EspInstanceWindow s_instance;
        return &s_instance;
    }

public:
    EspInstanceWindow();

    virtual void OnInit();
    virtual void OnEvent();
    virtual void Render();
    virtual void Flush(int x, int y, int width, int height);

public:
    // void InitUI();

protected:
    esp_lcd_panel_handle_t m_lcd_panel_handle;
    uint16_t *m_frame_buffers;
    uint16_t *m_frame_buffers_0;
    uint16_t *m_frame_buffers_1;

public:
    static void DumpMemory();
};

#endif